import 'package:flutter/cupertino.dart';

import 'explore_all/explore_all.dart';
import 'explore_calender/explore_calender.dart';

class IndexPage extends StatefulWidget {
  const IndexPage({Key? key}) : super(key: key);

  @override
  State<IndexPage> createState() => _IndexPageState();
}

class _IndexPageState extends State<IndexPage> {
  int currentPage = 0;

  Map<Object, Widget> segmentedControlWidgets() {
    return {
      0: Container(
          padding: const EdgeInsets.only(left: 25, right: 25),
          child: const Text('浏览')),
      1: Container(
        padding: const EdgeInsets.only(left: 25, right: 25),
        child: const Text('日历'),
      ),
    };
  }

  @override
  Widget build(BuildContext context) {
    return CupertinoPageScaffold(
      navigationBar: CupertinoNavigationBar(
        middle: CupertinoSegmentedControl(
            children: segmentedControlWidgets(),
            groupValue: currentPage,
            onValueChanged: (value) {
              setState(() {
                currentPage = value as int;
              });
            }),
      ),
      child: Container(
        child: currentPage == 0
            ? const ExploreAllPage()
            : const ExploreCalenderPage(),
      ),
    );
  }
}
